// let chren = args.form;
// // chren.forEach(function(item,index,array){
// // 	let receipt_product_id = item.receiptProductId;
// // 	lib.dbUpdate('UPDATE receipt_product SET reflecti = 0,low_quality = receipt_num,no_qc_num = receipt_num,qc_status = 0 WHERE receipt_product_id = ?',receipt_product_id);
// // });
// let result = 0
// chren.forEach(function(item,index,array){
// 	let receipt_product_id = item.receiptProductId;
//   let r1 = lib.dbUpdate('UPDATE receipt_product SET reflecti = 0,low_quality = receipt_num,no_qc_num = receipt_num,qc_status = 0 WHERE id = (SELECT receipt_product_id FROM quality_check_storage WHERE id=?)',receipt_product_id);
//   result = result + r1;
// });
// result;


let result = 0
let id = args.form[0]["receiptProductId"];   
let r1 = lib.dbUpdate('UPDATE receipt_product rp INNER JOIN quality_check_storage  qcs ON rp.id=qcs.receipt_product_id SET rp.reflecti = rp.reflecti - qcs.product_receive_num,rp.low_quality = rp.low_quality + qcs.product_receive_num, rp.qc_status = if((select count(*) from quality_check_storage where del_flag = 0 and receipt_product_id in (SELECT receipt_product_id FROM quality_check_storage WHERE id= ? )) > 0, 2,0)  WHERE qcs.id = ? and rp.del_flag = 0',id,id);  
let q1 = lib.dbUpdate('update quality_check_storage set del_flag = 1 WHERE id =?',id);
result = result + q1; 
result;